const mongoose = require('mongoose')

const Schema = mongoose.Schema

const orderSchema = new Schema({
  id: {
    type: String,
    required: true
  },
  name: {
    type: String,
    required: true
  },
  foods: {
    type: Array,
    required: true
  },
  order_time: {
    type: String,
    required: true
  },
  price: {
    type: String,
    required: true
  },
  openid: {
    type: String,
    required: true
  },
  status: {
    type: String,
    enum : ['1','2', '3', '4'],
    default: '2'
  },
  order_no: {
    type: String,
    default: ""
    // new Date().getTime() + randomString(10)
  },
  payObj: {
    type: Object,
    default: {}
  },
  easy_no: {
    type: String,
    default: ""
  },
  order_status: {
    type: String,
    enum : ['已完成', '制作中', '未开始', '支付失败'],
    default: '未开始'
  },
  store: {
    type: String,
    enum: ['1', '2'],
    default: '1'
  },
  remark: {
    type: String,
    default: ''
  },
  

  // 非必须
  created_time: {
    type: Date,
    default: Date.now
  },
  last_modified_time: {
    type: Date,
    default: Date.now
  }, 
})

module.exports = mongoose.model('Order', orderSchema)